{ We draw pages horizontally first, then vertically, so if there are four pages, page 2 is to the right of page 1. }
{ First, get the offset rectangle for the page we're drawing }
offsetPage := thePicture^^.picFrame;
OffsetRect(offsetPage, -((pageNumber - 1) mod pageDims.width) * (thePage.right - thePage.left), -((pageNumber - 1) div pageDims.width) * (thePage.bottom - thePage.top));
DrawPicture(thePicture, offsetPage);
end;
procedure MyPIdleProcedure;
var
pIdleEventRecord: EventRecord;
begin
if GetNextEvent(keyDownMask, pIdleEventRecord) then
begin
if ((BitAnd(pIdleEventRecord.message, charCodeMask) = longint('.')) and (BitAnd(longint(pIdleEventRecord.modifiers), cmdKey) = cmdKey)) then
PrSetError(iPrAbort);
end;
end;
function PageSetup (thePrRecHdl: THPrint): boolean;
var
PrintError: LongInt;
oldPort: GrafPtr;
printmgrsResFile: integer;
begin
GetPort(oldPort);
printmgrsResFile := CurResFile;
if thePrRecHdl <> nil then
begin
PrOpen;
if (PrError = noErr) then
begin
if (PrError = noErr) then
begin
if (PrStlDialog(thePrRecHdl)) then
{ Do any post-processing on the style dialog results you need to here }
else
PrSetError(iPrAbort); {** Cancel from the style dialog **}
end;
end;
PrintError := PrError;
PrClose;
{**}
{ You do not want to report any printing errors}
{ until you}
{ have fallen through the printing loop . This will make sure that ALL of the Print Manager 's open calls have their corresponding close calls, thereby}
{ enabling the Print Manager to close properly and that all temporary memory allocations are released . * *}
if (PrintError <> noErr) and (PrintError <> iPrAbort) then
{ PostPrintingErrors(PrintError); Need to add this }
{ Print the range of pages of the document requested by the user from the Print Job Dialog . * *}
pageNumber := firstPage;
while ((pageNumber <= lastPage) and (PrError = noErr)) do
begin
PrOpenPage(thePrPort, nil);
if (PrError = noErr) then
begin
{**}
{ rPage ( IM II - 150 ) is the printable area}
{ for the currently selected printer . By passing the current enables your app to use the same routine to draw to the screen and the printer 's GrafPort.}
{ The printing job is being canceled by the request of the user from the Print Style Dialog or the Print Job Dialog . PrError will be}
{ set to iPrAbort to tell the Print Manager to abort the current printing job . * *}
end
else
PrSetError(iPrAbort); {** Cancel from the job dialog **}
end;
end;
if (thePrRecHdl^^.prJob.bJDocLoop = bSpoolLoop) and (PrError = noErr) then
PrPicFile(thePrRecHdl, nil, nil, nil, theStatus);
{**}
{ Grab the printing error before you close the Print Manager and the error disappears . * *}
PrintError := PrError;
PrClose;
{**}
{ You do not want to report any printing errors}
{ until you}
{ have fallen through the printing loop . This will make sure that ALL of the Print Manager 's open calls have their corresponding close calls, thereby}
{ enabling the Print Manager to close properly and that all temporary memory allocations are released . * *}
if (PrintError <> noErr) then
{ PostPrintingErrors(PrintError); Need to add this }